﻿@using NewRen.Models;
@using NewRen.Models.ViewModel;
@model NewRen.Models.ViewModel.vEdit

@{
    User user = ViewBag.user as User;
    ViewBag.Title = "牛人设置-牛人修改";
    Layout = "~/Views/Shared/_Layout_Show.cshtml";

}
<script>
    function EditCheck() {
        if (!CheckPhone()) return false;
        if (!CheckEmail()) return false;
    }

    function CheckPhone() {
        if ($("#Phone").val() != "") {
            if ($("#Phone").val().length > 14 || $("#Phone").val().length < 6) {
                CastMsg("电话格式不正确");
                return false;
            }
        }
        return true;
    }
    function CheckEmail() {
        if ($("#Email").val() != "") {
            var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
            if (!myreg.test($("#Email").val())) {
                CastMsg("邮箱格式输入错误！");
                return false;
            }
        }
        return true;
    }


</script>
<div class="ucenter-left account-left-border">
    <div class="ucneter-l-head cf">
        <div class="ulhead-headicon">
            @if (user.Picture == null)
            {
                <img src="/Images/userphoto.png" width="50" height="50"
                     alt=@user.UserName style="border-radius:50%;" />
            }
            else
            {
                <img src="/User/ShowPicture/@user.ID" width="50"
                     alt=@user.UserName height="50" style="border-radius:50%;" />
            }

        </div>
        <div class="ulhead-info">
            <p class="ulhead-info-uname">@user.UserName</p>

            <div class="ulhead-info-tool">
                <a class="ulhead-icon icon-lock ucenter-mail " href="/User/PwdEdit/@user.ID" title="修改密码">
                    <div class="ucenter-mail-tip">修改密码</div>
                </a>
                <a href="/User/Edit/@user.ID"
                   class="ulhead-icon icon-setting ucenter-mail" title="设置个人信息"></a>
            </div>
        </div>
    </div>
    <div class="ucenter-l-list">
        <ul class="ullist-ul">
            <li id="uclick">
                <a href="/User/Show/@user.ID">个人中心</a>
            </li>
            <li id="uclick2">
                <a href="/User/DescriptionShow/@user.ID">个人概述</a>
            </li>
            <li id="uclick3" class="active">
                <a href="/User/Edit/@user.ID">账号设置</a>
            </li>
            <li id="uclick4">
                <a href="/User/IntegrationShow/@user.ID">收支明细</a>
            </li>
            <li id="uclick5">
                <a href="/User/CollectManager/@user.ID">我的收藏</a>
            </li>
            <li id="uclick6">
                <a href="/User/BrowseRecord/@user.ID">浏览记录</a>
            </li>
           <!-- <li id="uclick7">
                <a href="/User/PayMoney/@user.ID">充值</a>
            </li>-->
        </ul>
    </div>
</div>
<div class="ucenter-right cf">
    <div class="ucenter-right-head">
        <span class="ucenter-right-head-selected"><a href="/User/Edit/@user.ID">信息修改</a></span>
        <span class="ucenter-right-head-show"><a href="/User/PwdEdit/@user.ID">密码修改</a></span>
        <span class="ucenter-right-head-show"><a href="/User/PictureEdit/@user.ID">更换头像</a></span>
    </div>
    <div class="tabGroup">
        @using (Html.BeginForm("Edit", "User", FormMethod.Post, new { onsubmit = "return EditCheck();" }))
        {
            @Html.AntiForgeryToken()
                <div class=" form-item">
                    <div class="item-label">
                        <label>真实姓名：</label>
                    </div>
                    <div class="item-span">
                        @Html.TextBoxFor(model => model.RealName, new { @Value = user.RealName, @class = "txt sm" })
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>性别：</label>
                    </div>
                    <div class="item-span">
                        @Html.DropDownListFor(model => model.SexAsInt, ViewBag.Sex as IEnumerable<SelectListItem>, new { @class = "select w-xs" })
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>生日：</label>
                    </div>
                    <div class="item-span">
                        <input type="text" value="@(user.Birthday.HasValue?user.Birthday.Value.ToString("yyyy/MM/dd"):"")" id="Birthday" name="Birthday" class="date txt sm" onclick="date()">
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>电话：</label>
                    </div>
                    <div class="item-span">
                        @Html.TextBoxFor(model => model.Phone, new { @Value = user.Phone, @class = "txt sm" })
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>QQ：</label>
                    </div>
                    <div class="item-span">
                        @Html.TextBoxFor(model => model.QQ, new { @Value = user.QQ, @class = "txt sm" })
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>微博：</label>
                    </div>
                    <div class="item-span">
                        @Html.TextBoxFor(model => model.Weibo, new { @Value = user.Weibo, @class = "txt sm" })
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>邮箱：</label>
                    </div>
                    <div class="item-span">
                        @Html.TextBoxFor(model => model.Email, new { @Value = user.Email, @class = "txt sm" })
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>微信：</label>
                    </div>
                    <div class="item-span">
                        @Html.TextBoxFor(model => model.WhatApp, new { @Value = user.WhatApp, @class = "txt sm" })
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>工作：</label>
                    </div>
                    <div class="item-span">
                        <select id="job" name="job" class="select">
                            @foreach (Job item in ViewBag.Jobs)
                            {
                                <option value="@item.JobName">@item.JobName</option>
                            }
                        </select>
                        @if (user.Job != null)
                        {
                            <script>
                                $("#job").val("@user.Job");
                            </script>
                        }
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>所在城市：</label>
                    </div>
                    <div class="item-span">
                        <select id="city_list" name="cityID" class="select">
                            @foreach (City item in ViewBag.Cities)
                            {
                                <option value="@item.ID">@item.CityName</option>
                            }
                        </select>
                        <script>
                            if ("@user.City" != "") {
                                //设置城市默认值
                                for (var i = 0; i < $("#city_list option").length; i++) {
                                    if ($("#city_list").get(0).options[i].text == "@user.City") {
                                        $("#city_list").get(0).options[i].selected = true;
                                        break;
                                    }
                                }
                            }
                        </script>
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>所在区县：</label>
                    </div>
                    <div class="item-span">
                        <select id="district_list" name="districtID" class="select"></select>
                    </div>
                    <script>
                        if ("@user.District" != "") {
                            getDistrict("@user.District", "@user.Town");
                        }
                    </script>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>所在乡镇：</label>
                    </div>
                    <div class="item-span">
                        <select id="town_list" name="townID" class="select"></select>
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>地址：</label>
                    </div>
                    <div class="item-span">
                        @Html.TextBoxFor(model => model.Address, new { @Value = user.Address, @class = "txt sm" })
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">
                        <label>自我描述：</label>
                    </div>
                    <div class="item-span">
                        <textarea class="resize-none" name="description" id="description">@user.Description</textarea>
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-span">
                        <input type="submit" value="保存" class="btn">
                    </div>
                </div>
        }
    </div>
</div>
